package edu.sctu.wujiayi.month06.day20150629;

import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;

import java.io.*;
import java.text.MessageFormat;

/**
 * Created by user11 on 2015/6/29.
 */
public class SerialPractice {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        serialDayClient();
        DayClient dayClient = opSerialDayClient();
        System.out.println(dayClient.getName()+dayClient.getSex()+dayClient.getAge()+dayClient.getNumber());
        System.out.println(MessageFormat.format(dayClient.getName(),dayClient.getNumber()));


    }

    public static void serialDayClient() throws IOException {
        DayClient dayClient = new DayClient();
        dayClient.setAge(19);
        dayClient.setName("吴佳怡");
        dayClient.setNumber(14061010);
        dayClient.setSex("女");
        ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(new File("D://nath//sherlock.txt")));
        out.writeObject(dayClient);
        System.out.println("序列化成功");
    }
    public static DayClient opSerialDayClient() throws IOException, ClassNotFoundException {
        ObjectInputStream ob = new ObjectInputStream(new FileInputStream(new File("D://nath//sherlock.txt")));
        DayClient dayClient = (DayClient) ob.readObject();
        System.out.println("反序列化成功");
        return dayClient;
    }
}
